-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataViews: Add density option to table
layout
#67170
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @annchichi. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +549 B (+0.03%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
fe0ada1
to
77f3a3f
Compare
return _density; | ||
} ); | ||
}, [ setDensity, viewport ] ); | ||
const gridColumns = view.layout?.gridColumns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This effect was changed to a hook and essentially changes conditionally the grid columns on viewport change.
Before it was only effective when the view options dropdown was open, so I'm using it at the main grid
layout code.
Screen.Recording.2024-11-21.at.10.17.43.AM.mov
@@ -169,6 +169,21 @@ | |||
opacity: 1; | |||
} | |||
} | |||
|
|||
// Density style overrides. | |||
&.has-compact-density { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we'll add the density styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we'll add the density styles.
@ntsekourasI was wondering if it’s possible for a density style to include a different type size (within the defined typesscale), or is it limited to just spacing variants like padding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include a different type size
You mean font sizes? In general I added these changes as a placeholder and designers will decide how the table should look per density.
@ntsekouras the screen recording looks awesome and I think the density settings will be very useful to our users :) |
packages/dataviews/src/components/dataviews-view-config/index.tsx
Outdated
Show resolved
Hide resolved
density={ density } | ||
setDensity={ setDensity } | ||
/> | ||
{ !! usedLayout?.viewConfigOptions && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consumers can provide default data for the density via view.layout.density
. That's nice. How could they disable this layout-specific config so it still takes a value (e.g.: compact
) and users cannot change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! It feels like we'd need a new API for something like that, no? Maybe something like what Query Loop does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how that translates to a DataView concept, could you ellaborate? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it could be by having an extra prop in view.layout
which could be something like view.layout.renderControls: ['density']
. Having an empty array there could mean do not render any viewConfigOptions
. I think we'd need a bit more time to see how viewConfigOptions
evolves to start exploring a good way to support this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could work, though we need to figure out a few things:
- sort & order are configured by the Field API: if no field is sortable they won't be available
- pagination & field config (moving but also field visibility) cannot be disabled and are controlled by the view config component
- the view config doesn't have information about the layout-specific view configs (density, preview size)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments but direction sounds good. I'll do a second review after design feedback has come in.
d53a798
to
e41a211
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me for a v1.
.fields-controls__featured-image-placeholder { | ||
width: 32px; | ||
height: 32px; | ||
display: block; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous bug. The lack of display
property was creating whitespace beneath the featured image which messed up alignment.
Flaky tests detected in e657fc8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12008079372
|
@@ -35,7 +35,6 @@ import { useInstanceId } from '@wordpress/compose'; | |||
*/ | |||
import { | |||
SORTING_DIRECTIONS, | |||
LAYOUT_GRID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an improvement: we have only the LAYOUT_TABLE dependency here. 🎉
What?
Resolves: #66312
This PR adds a
density
option totable
layout. I first explored whether an abstraction for thedensity
concept could be a good fit for layouts, but after discussions and better consideration it's better not to rush to such abstraction. The main reason is thedensity
forgrid
for example might confuse users, because common expectations would be a clear setting for controlling the columns(preview size).Having said that, this PR adds a viewConfigOptions to layouts, where layouts can optionally add some specific controls (React components) in a specific place in the
view options
dropdown.By doing that, we decouple the previews grid's
preview size
control from the DataViews core components code and the layout is responsible for providing this control. Additionally these props have been moved insideview.layout
object, since they are specific to each layout.Tasks
density
control and available optionstable
layout perdensity
optionTesting instructions
density
option intable
layoutpreview size
option in `grid layout (they should behave the same with trunk with an improvement to auto adjust when the viewport changes)Screenshots
Screen.Recording.2024-11-21.at.9.07.27.AM.mov